import UserModel from "../../../../models/User";
// import Compare from "../../../../utils/Compare";

const userModel = new UserModel()

Page({
  data: {

  },
  onLoad: function (options) {
    // const ver = wx.getSystemInfoSync().SDKVersion
    // if (Compare(ver, '2.10.4') < 0) {
    //   return wx.showModal({
    //     title: '提示',
    //     content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。'
    //   })
    // }
  },

  onGetInfo() {
    wx.getUserProfile({
      desc: '用于完善会员资料',
      success: res => {
        if (res.userInfo) {
          const avatar = res.userInfo.avatarUrl

          const nickname = res.userInfo.nickName
          const sex = res.userInfo.gender
          userModel.saveUserInfo({ avatar, nickname, sex }).then(() => {
            wx.switchTab({
              url: '/pages/center/index'
            })
          })
        }
      }
    })
  }
});
